1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module pango.PgLayoutLine; 26 27 private import glib.ListSG; 28 private import glib.MemorySlice; 29 private import gobject.ObjectG; 30 private import linker.Loader; 31 private import pango.PgLayout; 32 private import pango.c.functions; 33 public import pango.c.types; 34 35 36 /** 37 * A `PangoLayoutLine` represents one of the lines resulting from laying 38 * out a paragraph via `PangoLayout`. 39 * 40 * `PangoLayoutLine` structures are obtained by calling 41 * [method@Pango.Layout.get_line] and are only valid until the text, 42 * attributes, or settings of the parent `PangoLayout` are modified. 43 */ 44 public final class PgLayoutLine 45 { 46 /** the main Gtk struct */ 47 protected PangoLayoutLine* pangoLayoutLine; 48 protected bool ownedRef; 49 50 /** Get the main Gtk struct */ 51 public PangoLayoutLine* getPgLayoutLineStruct(bool transferOwnership = false) 52 { 53 if (transferOwnership) 54 ownedRef = false; 55 return pangoLayoutLine; 56 } 57 58 /** the main Gtk struct as a void* */ 59 protected void* getStruct() 60 { 61 return cast(void*)pangoLayoutLine; 62 } 63 64 /** 65 * Sets our main struct and passes it to the parent class. 66 */ 67 public this (PangoLayoutLine* pangoLayoutLine, bool ownedRef = false) 68 { 69 this.pangoLayoutLine = pangoLayoutLine; 70 this.ownedRef = ownedRef; 71 } 72 73 ~this () 74 { 75 if ( Linker.isLoaded(LIBRARY_PANGO[0]) && ownedRef ) 76 pango_layout_line_unref(pangoLayoutLine); 77 } 78 79 80 /** 81 * the layout this line belongs to, might be %NULL 82 */ 83 public @property PgLayout layout() 84 { 85 return ObjectG.getDObject!(PgLayout)(pangoLayoutLine.layout, false); 86 } 87 88 /** Ditto */ 89 public @property void layout(PgLayout value) 90 { 91 pangoLayoutLine.layout = value.getPgLayoutStruct(); 92 } 93 94 /** 95 * start of line as byte index into layout->text 96 */ 97 public @property int startIndex() 98 { 99 return pangoLayoutLine.startIndex; 100 } 101 102 /** Ditto */ 103 public @property void startIndex(int value) 104 { 105 pangoLayoutLine.startIndex = value; 106 } 107 108 /** 109 * length of line in bytes 110 */ 111 public @property int length() 112 { 113 return pangoLayoutLine.length; 114 } 115 116 /** Ditto */ 117 public @property void length(int value) 118 { 119 pangoLayoutLine.length = value; 120 } 121 122 /** 123 * list of runs in the 124 * line, from left to right 125 */ 126 public @property ListSG runs() 127 { 128 return new ListSG(pangoLayoutLine.runs, false); 129 } 130 131 /** Ditto */ 132 public @property void runs(ListSG value) 133 { 134 pangoLayoutLine.runs = value.getListSGStruct(); 135 } 136 137 138 /** 139 * #Resolved PangoDirection of line 140 */ 141 public @property uint resolvedDir() 142 { 143 return pangoLayoutLine.resolvedDir; 144 } 145 146 /** Ditto */ 147 public @property void resolvedDir(uint value) 148 { 149 pangoLayoutLine.resolvedDir = value; 150 } 151 152 /** */ 153 public static GType getType() 154 { 155 return pango_layout_line_get_type(); 156 } 157 158 /** 159 * Computes the logical and ink extents of a layout line. 160 * 161 * See [method@Pango.Font.get_glyph_extents] for details 162 * about the interpretation of the rectangles. 163 * 164 * Params: 165 * inkRect = rectangle used to store the extents of 166 * the glyph string as drawn 167 * logicalRect = rectangle used to store the logical 168 * extents of the glyph string 169 */ 170 public void getExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect) 171 { 172 pango_layout_line_get_extents(pangoLayoutLine, &inkRect, &logicalRect); 173 } 174 175 /** 176 * Computes the height of the line, as the maximum of the heights 177 * of fonts used in this line. 178 * 179 * Note that the actual baseline-to-baseline distance between lines 180 * of text is influenced by other factors, such as 181 * [method@Pango.Layout.set_spacing] and 182 * [method@Pango.Layout.set_line_spacing]. 183 * 184 * Params: 185 * height = return location for the line height 186 * 187 * Since: 1.44 188 */ 189 public void getHeight(out int height) 190 { 191 pango_layout_line_get_height(pangoLayoutLine, &height); 192 } 193 194 /** 195 * Returns the length of the line, in bytes. 196 * 197 * Returns: the length of the line 198 * 199 * Since: 1.50 200 */ 201 public int getLength() 202 { 203 return pango_layout_line_get_length(pangoLayoutLine); 204 } 205 206 /** 207 * Computes the logical and ink extents of @layout_line in device units. 208 * 209 * This function just calls [method@Pango.LayoutLine.get_extents] followed by 210 * two [func@extents_to_pixels] calls, rounding @ink_rect and @logical_rect 211 * such that the rounded rectangles fully contain the unrounded one (that is, 212 * passes them as first argument to [func@extents_to_pixels]). 213 * 214 * Params: 215 * inkRect = rectangle used to store the extents of 216 * the glyph string as drawn 217 * logicalRect = rectangle used to store the logical 218 * extents of the glyph string 219 */ 220 public void getPixelExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect) 221 { 222 pango_layout_line_get_pixel_extents(pangoLayoutLine, &inkRect, &logicalRect); 223 } 224 225 /** 226 * Returns the resolved direction of the line. 227 * 228 * Returns: the resolved direction of the line 229 * 230 * Since: 1.50 231 */ 232 public PangoDirection getResolvedDirection() 233 { 234 return pango_layout_line_get_resolved_direction(pangoLayoutLine); 235 } 236 237 /** 238 * Returns the start index of the line, as byte index 239 * into the text of the layout. 240 * 241 * Returns: the start index of the line 242 * 243 * Since: 1.50 244 */ 245 public int getStartIndex() 246 { 247 return pango_layout_line_get_start_index(pangoLayoutLine); 248 } 249 250 /** 251 * Gets a list of visual ranges corresponding to a given logical range. 252 * 253 * This list is not necessarily minimal - there may be consecutive 254 * ranges which are adjacent. The ranges will be sorted from left to 255 * right. The ranges are with respect to the left edge of the entire 256 * layout, not with respect to the line. 257 * 258 * Params: 259 * startIndex = Start byte index of the logical range. If this value 260 * is less than the start index for the line, then the first range 261 * will extend all the way to the leading edge of the layout. Otherwise, 262 * it will start at the leading edge of the first character. 263 * endIndex = Ending byte index of the logical range. If this value is 264 * greater than the end index for the line, then the last range will 265 * extend all the way to the trailing edge of the layout. Otherwise, 266 * it will end at the trailing edge of the last character. 267 * ranges = location to 268 * store a pointer to an array of ranges. The array will be of length 269 * `2*n_ranges`, with each range starting at `(*ranges)[2*n]` and of 270 * width `(*ranges)[2*n + 1] - (*ranges)[2*n]`. This array must be freed 271 * with g_free(). The coordinates are relative to the layout and are in 272 * Pango units. 273 */ 274 public void getXRanges(int startIndex, int endIndex, out int[] ranges) 275 { 276 int* outranges; 277 int nRanges; 278 279 pango_layout_line_get_x_ranges(pangoLayoutLine, startIndex, endIndex, &outranges, &nRanges); 280 281 ranges = outranges[0 .. nRanges]; 282 } 283 284 /** 285 * Converts an index within a line to a X position. 286 * 287 * Params: 288 * index = byte offset of a grapheme within the layout 289 * trailing = an integer indicating the edge of the grapheme to retrieve 290 * the position of. If > 0, the trailing edge of the grapheme, 291 * if 0, the leading of the grapheme 292 * xPos = location to store the x_offset (in Pango units) 293 */ 294 public void indexToX(int index, bool trailing, out int xPos) 295 { 296 pango_layout_line_index_to_x(pangoLayoutLine, index, trailing, &xPos); 297 } 298 299 /** 300 * Returns whether this is the first line of the paragraph. 301 * 302 * Returns: %TRUE if this is the first line 303 * 304 * Since: 1.50 305 */ 306 public bool isParagraphStart() 307 { 308 return pango_layout_line_is_paragraph_start(pangoLayoutLine) != 0; 309 } 310 311 alias doref = ref_; 312 /** 313 * Increase the reference count of a `PangoLayoutLine` by one. 314 * 315 * Returns: the line passed in. 316 * 317 * Since: 1.10 318 */ 319 public PgLayoutLine ref_() 320 { 321 auto __p = pango_layout_line_ref(pangoLayoutLine); 322 323 if(__p is null) 324 { 325 return null; 326 } 327 328 return ObjectG.getDObject!(PgLayoutLine)(cast(PangoLayoutLine*) __p, true); 329 } 330 331 /** 332 * Decrease the reference count of a `PangoLayoutLine` by one. 333 * 334 * If the result is zero, the line and all associated memory 335 * will be freed. 336 */ 337 public void unref() 338 { 339 pango_layout_line_unref(pangoLayoutLine); 340 } 341 342 /** 343 * Converts from x offset to the byte index of the corresponding character 344 * within the text of the layout. 345 * 346 * If @x_pos is outside the line, @index_ and @trailing will point to the very 347 * first or very last position in the line. This determination is based on the 348 * resolved direction of the paragraph; for example, if the resolved direction 349 * is right-to-left, then an X position to the right of the line (after it) 350 * results in 0 being stored in @index_ and @trailing. An X position to the 351 * left of the line results in @index_ pointing to the (logical) last grapheme 352 * in the line and @trailing being set to the number of characters in that 353 * grapheme. The reverse is true for a left-to-right line. 354 * 355 * Params: 356 * xPos = the X offset (in Pango units) from the left edge of the line. 357 * index = location to store calculated byte index for the grapheme 358 * in which the user clicked 359 * trailing = location to store an integer indicating where in the 360 * grapheme the user clicked. It will either be zero, or the number of 361 * characters in the grapheme. 0 represents the leading edge of the grapheme. 362 * 363 * Returns: %FALSE if @x_pos was outside the line, %TRUE if inside 364 */ 365 public bool xToIndex(int xPos, out int index, out int trailing) 366 { 367 return pango_layout_line_x_to_index(pangoLayoutLine, xPos, &index, &trailing) != 0; 368 } 369 }